<template>
  <div>
    <el-steps :active="3" simple>
      <el-step title="课程基础信息" icon="el-icon-edit"></el-step>
      <el-step title="课程大纲" icon="el-icon-upload"></el-step>
      <el-step title="课程发布" icon="el-icon-picture"></el-step>
    </el-steps>
    <div class="ccInfo">
      <img :src="getPublish.cover" />
      <div class="main">
        <h2>{{ getPublish.title }}</h2>
        <p class="gray">
          <span>共{{ getPublish.lessonNum }}课时</span>
        </p>
        <p>
          <span
            >所属分类：{{ getPublish.subjectLevelOne }} —
            {{ getPublish.subjectLevelTwo }}</span
          >
        </p>
        <p>课程讲师：{{ getPublish.teacherName }}</p>
        <h3 class="red">￥{{ getPublish.price }}</h3>
      </div>
    </div>
    <el-button
      style="margin-top: 12px;"
      :disabled="saveBtnDisabled"
      @click="back"
      >返回修改</el-button
    >
    <el-button
      style="margin-top: 12px;"
      :disabled="saveBtnDisabled"
      @click="publish"
      >发布课程</el-button
    >
  </div>
</template>

<script>
import coursePublishApi from "@/api/edu/publish.js";
export default {
  data() {
    return {
      active: 0,
      saveBtnDisabled: false,
      courseId: "",
      getPublish: {}
    };
  },
  created() {
    // 获取到路由id
    if (this.$route.params && this.$route.params.id) {
      this.courseId = this.$route.params.id;
      this.getCoursePublish();
    }
  },
  methods: {
    back() {
      this.$router.push({ path: "/Learning/course/chapter/" + this.courseId });
    },
    publish() {
      this.updateStatus();
      this.$router.push({ path: "/Learning/course/list" });
    },
    getCoursePublish() {
      coursePublishApi
        .getCoursePublish(this.courseId)
        .then(response => {
          this.getPublish = response.data.coursePublish;
        })
        .catch(error => {});
    },
    updateStatus() {
      coursePublishApi
        .updateCourseStatus(this.courseId)
        .then(response => {
          console.log(response);
          this.$message({
            type: "success",
            message: response.message
          });
        })
        .catch(error => {});
    }
  }
};
</script>
<style scoped>
.ccInfo {
  background: #f5f5f5;
  padding: 20px;
  overflow: hidden;
  border: 1px dashed #ddd;
  margin-bottom: 40px;
  position: relative;
}
.ccInfo img {
  background: #d6d6d6;
  width: 500px;
  height: 278px;
  display: block;
  float: left;
  border: none;
}
.ccInfo .main {
  margin-left: 520px;
}

.ccInfo .main h2 {
  font-size: 28px;
  margin-bottom: 30px;
  line-height: 1;
  font-weight: normal;
}
.ccInfo .main p {
  margin-bottom: 10px;
  word-wrap: break-word;
  line-height: 24px;
  max-height: 48px;
  overflow: hidden;
}

.ccInfo .main p {
  margin-bottom: 10px;
  word-wrap: break-word;
  line-height: 24px;
  max-height: 48px;
  overflow: hidden;
}
.ccInfo .main h3 {
  left: 540px;
  bottom: 20px;
  line-height: 1;
  font-size: 28px;
  color: #d32f24;
  font-weight: normal;
  position: absolute;
}
</style>
